

import queue, threading, time

q = queue.Queue(maxsize=10)
# q = queue.LifoQueue(maxsize=10)

def producer(name):
    count = 1
    while True:
        q.put('包子%s，' % count)  #写入队列
        print('生产了包子：', count)
        count+=1
        time.sleep(0.1)

def Consumer(name):
    while True:
        print('[%s]取到了[%s]并吃了他，，' % (name, q.get()))
        time.sleep(1)

p = threading.Thread(target=producer, args=('生产者',))
c = threading.Thread(target=Consumer, args=('刘奇',))
c2 = threading.Thread(target=Consumer, args=('强哥',))

p.start()
c.start()
c2.start()
